#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Chassis {
public:
    void setAttributes(string chassisID, string model, double wheelbase, double track,
        double groundClearance, double minTurningRadius, string driveType, double maxRange);
    void print();
    void save(ofstream& file);

private:
    string chassisID;
    string model;
    double wheelbase;
    double track;
    double groundClearance;
    double minTurningRadius;
    string driveType;
    double maxRange;
};

class Tire {
public:
    void setAttributes(string model, double size);
    void print();
    void save(ofstream& file);

private:
    string model;
    double size;
};

class AGX {
public:
    void setAttributes(string model, double ai, int cudaCores, int tensorCores, double memory, double storage);
    void print();
    void save(ofstream& file);

private:
    string model;
    double ai;
    int cudaCores;
    int tensorCores;
    double memory;
    double storage;
};

class Camera {
public:
    void setAttributes(string model, string camera, string resolution, int frameRate, int fov, int depthFrameRate);
    void print();
    void save(ofstream& file);

private:
    string model;
    string camera;
    string resolution;
    int frameRate;
    int fov;
    int depthFrameRate;
};

class Lidar {
public:
    void setAttributes(string model, int channels, double testRange, double powerConsumption);
    void print();
    void save(ofstream& file);

private:
    string model;
    int channels;
    double testRange;
    double powerConsumption;
};

class Gyroscope {
public:
    void setAttributes(string model, string manufacturer);
    void print();
    void save(ofstream& file);

private:
    string model;
    string manufacturer;
};

class Display {
public:
    void setAttributes(double size, string model);
    void print();
    void save(ofstream& file);

private:
    double size;
    string model;
};

class Battery {
public:
    void setAttributes(string parameters, double externalPower, double chargingTime);
    void print();
    void save(ofstream& file);

private:
    string parameters;
    double externalPower;
    double chargingTime;
};

class Student {
public:
    void inputInfoFromConsole();
    void setAttributes(string studentID, string name);
    void print();
    void save(ofstream& file);

private:
    string studentID;
    string name;
};

class Car {
public:
    Car();
    void setID(string carID);
    void assignToStudent(Student& student);
    void print();
    void save(ofstream& file);

public:
    string carID;
    Chassis chassis;
    Tire tires[4];
    AGX agx;
    Camera camera;
    Lidar lidar;
    Gyroscope gyroscope;
    Display display;
    Battery battery;
    Student student;
};

void Chassis::setAttributes(string chassisID, string model, double wheelbase, double track,
    double groundClearance, double minTurningRadius, string driveType, double maxRange) {
    this->chassisID = chassisID;
    this->model = model;
    this->wheelbase = wheelbase;
    this->track = track;
    this->groundClearance = groundClearance;
    this->minTurningRadius = minTurningRadius;
    this->driveType = driveType;
    this->maxRange = maxRange;
}

void Chassis::print() {
    cout << "���̣�" << endl;
    cout << "��ţ�" << chassisID << endl;
    cout << "�ͺţ�" << model << endl;
    cout << "��ࣺ" << wheelbase << "mm" << endl;
    cout << "�־ࣺ" << track << "mm" << endl;
    cout << "��С��ؼ�϶��" << groundClearance << "mm" << endl;
    cout << "��Сת��뾶��" << minTurningRadius << "m" << endl;
    cout << "������ʽ��" << driveType << endl;
    cout << "����г̣�" << maxRange << "KM" << endl;
}

void Chassis::save(ofstream& file) {
    file << "���̣�" << endl;
    file << "��ţ�" << chassisID << endl;
    file << "�ͺţ�" << model << endl;
    file << "��ࣺ" << wheelbase << "mm" << endl;
    file << "�־ࣺ" << track << "mm" << endl;
    file << "��С��ؼ�϶��" << groundClearance << "mm" << endl;
    file << "��Сת��뾶��" << minTurningRadius << "m" << endl;
    file << "������ʽ��" << driveType << endl;
    file << "����г̣�" << maxRange << "KM" << endl;
}

void Tire::setAttributes(string model, double size) {
    this->model = model;
    this->size = size;
}

void Tire::print() {
    cout << "��̥��" << endl;
    cout << "�ͺţ�" << model << endl;
    cout << "�ߴ磺" << size << "mm" << endl;
}

void Tire::save(ofstream& file) {
    file << "��̥��" << endl;
    file << "�ͺţ�" << model << endl;
    file << "�ߴ磺" << size << "mm" << endl;
}

void AGX::setAttributes(string model, double ai, int cudaCores, int tensorCores, double memory, double storage) {
    this->model = model;
    this->ai = ai;
    this->cudaCores = cudaCores;
    this->tensorCores = tensorCores;
    this->memory = memory;
    this->storage = storage;
}

void AGX::print() {
    cout << "AGX�׼���" << endl;
    cout << "�ͺţ�" << model << endl;
    cout << "AI��" << ai << " TOPS" << endl;
    cout << "CUDA���ģ�" << cudaCores << endl;
    cout << "Tensor CORE��" << tensorCores << endl;
    cout << "�Դ棺" << memory << "G" << endl;
    cout << "�洢��" << storage << "G" << endl;
}

void AGX::save(ofstream& file) {
    file << "AGX�׼���" << endl;
    file << "�ͺţ�" << model << endl;
    file << "AI��" << ai << " TOPS" << endl;
    file << "CUDA���ģ�" << cudaCores << endl;
    file << "Tensor CORE��" << tensorCores << endl;
    file << "�Դ棺" << memory << "G" << endl;
    file << "�洢��" << storage << "G" << endl;
}

void Camera::setAttributes(string model, string camera, string resolution, int frameRate, int fov, int depthFrameRate) {
    this->model = model;
    this->camera = camera;
    this->resolution = resolution;
    this->frameRate = frameRate;
    this->fov = fov;
    this->depthFrameRate = depthFrameRate;
}

void Camera::print() {
    cout << "˫Ŀ����ͷ��" << endl;
    cout << "�ͺţ�" << model << endl;
    cout << "����ͷ��" << camera << endl;
    cout << "RGB֡�ֱ��ʣ�" << resolution << endl;
    cout << "RGB֡�ʣ�" << frameRate << endl;
    cout << "FOV��" << fov << endl;
    cout << "���֡�ʣ�" << depthFrameRate << endl;
}

void Camera::save(ofstream& file) {
    file << "˫Ŀ����ͷ��" << endl;
    file << "�ͺţ�" << model << endl;
    file << "����ͷ��" << camera << endl;
    file << "RGB֡�ֱ��ʣ�" << resolution << endl;
    file << "RGB֡�ʣ�" << frameRate << endl;
    file << "FOV��" << fov << endl;
    file << "���֡�ʣ�" << depthFrameRate << endl;
}

void Lidar::setAttributes(string model, int channels, double testRange, double powerConsumption) {
    this->model = model;
    this->channels = channels;
    this->testRange = testRange;
    this->powerConsumption = powerConsumption;
}

void Lidar::print() {
    cout << "���߼����״" << endl;
    cout << "�ͺţ�" << model << endl;
    cout << "ͨ������" << channels << endl;
    cout << "���Է�Χ��" << testRange << "m" << endl;
    cout << "���ģ�" << powerConsumption << "W" << endl;
}

void Lidar::save(ofstream& file) {
    file << "���߼����״" << endl;
    file << "�ͺţ�" << model << endl;
    file << "ͨ������" << channels << endl;
    file << "���Է�Χ��" << testRange << "m" << endl;
    file << "���ģ�" << powerConsumption << "W" << endl;
}

void Gyroscope::setAttributes(string model, string manufacturer) {
    this->model = model;
    this->manufacturer = manufacturer;
}

void Gyroscope::print() {
    cout << "9�������ǣ�" << endl;
    cout << "�ͺţ�" << model << endl;
    cout << "���ң�" << manufacturer << endl;
}

void Gyroscope::save(ofstream& file) {
    file << "9�������ǣ�" << endl;
    file << "�ͺţ�" << model << endl;
    file << "���ң�" << manufacturer << endl;
}

void Display::setAttributes(double size, string model) {
    this->size = size;
    this->model = model;
}

void Display::print() {
    cout << "Һ����ʾ����" << endl;
    cout << "�ߴ磺" << size << "Ӣ��" << endl;
    cout << "�ͺţ�" << model << endl;
}

void Display::save(ofstream& file) {
    file << "Һ����ʾ����" << endl;
    file << "�ߴ磺" << size << "Ӣ��" << endl;
    file << "�ͺţ�" << model << endl;
}

void Battery::setAttributes(string parameters, double externalPower, double chargingTime) {
    this->parameters = parameters;
    this->externalPower = externalPower;
    this->chargingTime = chargingTime;
}

void Battery::print() {
    cout << "���ģ�飺" << endl;
    cout << "������" << parameters << endl;
    cout << "���⹩�磺" << externalPower << "V" << endl;
    cout << "���ʱ����" << chargingTime << "H" << endl;
}

void Battery::save(ofstream& file) {
    file << "���ģ�飺" << endl;
    file << "������" << parameters << endl;
    file << "���⹩�磺" << externalPower << "V" << endl;
    file << "���ʱ����" << chargingTime << "H" << endl;
}

void Student::setAttributes(string studentID, string name) {
    this->studentID = studentID;
    this->name = name;
}

void Student::print() {
    cout << "ѧ����Ϣ��" << endl;
    cout << "ѧ�ţ�" << studentID << endl;
    cout << "������" << name << endl;
}

void Student::save(ofstream& file) {
    file << "ѧ����Ϣ��" << endl;
    file << "ѧ�ţ�" << studentID << endl;
    file << "������" << name << endl;
}

void Student::inputInfoFromConsole() {
    cout << "������ѧ����Ϣ��" << endl;
    cout << "ѧ�ţ�";
    cin >> studentID;
    cout << "������";
    cin >> name;
}

// Car ��ķ���ʵ��
Car::Car() {
    carID = "";
}

void Car::setID(string carID) {
    this->carID = carID;
}

void Car::assignToStudent(Student& student) {
    this->student = student;
}

void Car::print() {
    cout << "����С����" << endl;
    cout << "��ţ�" << carID << endl;
    chassis.print();
    for (int i = 0; i < 4; i++) {
        tires[i].print();
    }
    agx.print();
    camera.print();
    lidar.print();
    gyroscope.print();
    display.print();
    battery.print();
}

void Car::save(ofstream& file) {
    file << "����С����" << endl;
    file << "��ţ�" << carID << endl;
    chassis.save(file);
    for (int i = 0; i < 4; i++) {
        tires[i].save(file);
    }
    agx.save(file);
    camera.save(file);
    lidar.save(file);
    gyroscope.save(file);
    display.save(file);
    battery.save(file);
}
